package model.semantics.unary;

import model.semantics.UnaryOperation;



/**
 * Wraps results around [-1, 1].
 * 
 * @author Anne Weng
 */
public class Wrap extends UnaryOperation
{
	protected boolean leftAssociative = false;
	
	public Wrap(int precedence)
	{
		super(precedence);
	}
	
    @Override
    protected double evaluateValue (double value)
    {
        while (value > 1)
        {
        	value = value - 2;
        }
        while (value < -1)
        {
        	value = value + 2;
        }
        return value;
    }
}
